//
//  ShareControlView.m
//  PlayCatchGame
//
//  Created by 流言 on 2018/3/1.
//  Copyright © 2018年 清正. All rights reserved.
//

#import "ShareControlView.h"
#import "NSArray+Sudoku.h"


@interface ShareControlView()

@property (nonatomic, copy)ViewBlock btnBlock;

@end


@implementation ShareControlView


- (void)awakeFromNib {
    [super awakeFromNib];
    
    NSArray *titles =@[@"微信好友", @"微信朋友圈", @"新浪微博", @"QQ好友", @"QQ空间"];
    NSArray *imageNames =@[@"share_weixin", @"pengyouquan", @"weibo", @"qq", @"kongjian"];

    for (NSInteger i =0; i<titles.count; i++) {
        ILButton *button =[[ILButton alloc]initWithFrame:CGRectMake(0, 0, 50, 50)];
        button.imageView.contentMode =UIViewContentModeScaleAspectFit;
        button.imageView.image =[UIImage imageNamed:imageNames[i]];
        button.label.text =titles[i];
        button.textImage_view_center =15.0;
        [button addTarget:self action:@selector(buttonClick:) forControlEvents:UIControlEventTouchUpInside];
        [self.bgShareView addSubview:button];
        [self.buttonArray addObject:button];
    }
    [self.buttonArray mas_distributeSudokuViewsWithFixedItemWidth:0
                                                  fixedItemHeight:0
                                                 fixedLineSpacing:10
                                            fixedInteritemSpacing:15
                                                        warpCount:3
                                                       topSpacing:0
                                                    bottomSpacing:0
                                                      leadSpacing:10
                                                      tailSpacing:10];
}


- (void)buttonClick:(ILButton*)button {
    if (self.btnBlock) {
        self.btnBlock(button);
    }
}

- (void)didButtonClickBlock:(ViewBlock)newBlock {
    self.btnBlock = newBlock;
}

- (NSMutableArray<ILButton *> *)buttonArray {
    if (!_buttonArray) {
        _buttonArray =[NSMutableArray array];
    }
    return _buttonArray;
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
